################################## 
############ Preamble ############ 
################################## 

# set language to English
Sys.setenv(LANG = "en")

# clean up
rm(list = ls())

# Set working directory: please set your own
#setwd("~/Dropbox/JOP third submission/JOP replication/")

# Load necessary packages
library(tidyverse)
library(haven)
library(readstata13)
library(interflex)

# Import dataset
munsize <- read.dta13("01_data/cis_data.dta")

# Set seed
set.seed(1409)

# Generate numeric variable with municipality size
munsize$municipality_size <- as.numeric(munsize$TAMUNI)

# Make the interflex plot
interflex(estimator = "binning", data = munsize,
          Y = "cabine_use", D = "pp_dummy", X = "municipality_size",
          na.rm = T,
          Ylabel = "use of private voting booth",
          Dlabel = "supporting PP",
          Xlabel = "municipality size",
          theme.bw = T,
          file = "04_plots/figured6.png")
